class User {
    constructor({name, type, alias, fp, socket, avatar}) {
        this.type = type
        this.name = name
        this.alias = alias
        this.perm = []
        this.fp = fp // 不能泄露 fingerprint 信息，防止用户冒充
        this.socket = socket //TODO: 用户离线检测
        this.avatar = avatar
    }
    async setInfo(obj) {
        //let r = await this.dao.userSetInfo(this.name, obj)
        Object.assign(this, obj)
        return this
    }
    setPermission(perm) {
        this.perm = perm
        return this
    }
    toSender() {
        // 脱敏信息。用于房间用户列表
        return {
            type        : this.type,
            name        : this.name,
            alias       : this.alias,
            permission  : this.perm,
            avatar      : this.avatar,
        }
    }
}

module.exports = User